package com.conversationboard.model;

import java.util.Date;

import com.conversationboard.config.Configuration;
import com.conversationboard.formatter.DateFormatter;

public class UploadedFile {

	private Date timestamp;
	private String originalFileName;
	private String fileName;
	private long size;
	private boolean image;


	public Date getTimestamp() {
		return timestamp;
	}


	public void setTimestamp(Date timestamp) {
		this.timestamp = timestamp;
	}


	public String getOriginalFileName() {
		return originalFileName;
	}


	public void setOriginalFileName(String originalFileName) {
		this.originalFileName = originalFileName;
	}


	public String getFileName() {
		return fileName;
	}


	public void setFileName(String fileName) {
		this.fileName = fileName;
	}


	public boolean isImage() {
		return image;
	}


	public void setImage(boolean image) {
		this.image = image;
	}


	public String getURL() {

		return "http://" + Configuration.getInstance().getDomainName() + Configuration.getInstance().getRoot() + "/files/" + this.getFileName() + "/" + this.getOriginalFileName();

	}


	public String getBBCode() {

		if (this.isImage()) {
			return "[img]" + this.getURL() + "[/img]";
		} else {
			return "[url=" + this.getURL() + "]" + this.getOriginalFileName() + "[/url]";
		}
	}


	public String getWhenUploaded() {
		return DateFormatter.prettyPrintTime(this.getTimestamp(), null, true, true);
	}


	public long getSize() {
		return size;
	}


	public void setSize(long size) {
		this.size = size;
	}

}
